package com.ruslan.magaz.web;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class OrderLine {
	private int totalPrice;
	private Date orderDate;
	private int orderId;

	public int getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(int totalPrice) {
		this.totalPrice = totalPrice;
	}

	public Date getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}
	
	public static List<OrderLine> getOrderLines(List rawOrderLines){
		List<OrderLine> resultList = new ArrayList<OrderLine>();
			for (Object[] line : (List<Object[]>) rawOrderLines){
				OrderLine orderLine = new OrderLine();
				orderLine.setOrderId((Integer) line[0]);
//				long totalPrice = (Long) Math.round((Double)line[1]);
				int totalPrice = ((Long) line[1]).intValue();
				orderLine.setTotalPrice(totalPrice);
				orderLine.setOrderDate((Date) line[2]);
				resultList.add(orderLine);
			}
			return resultList;
		}
}